package edu.ncu.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.ncu.entity.Contact;

public class MessageUtils {
    public static String getMessage(boolean isSystemMessage,String fromName,String message){
        try{
            Contact resultMessage = new Contact();
            //resultMessage.setSystem(isSystemMessage);
            resultMessage.setContent(message);
            if(fromName != null){
                // resultMessage.setFromName(fromName);
            }
            ObjectMapper mapper = new ObjectMapper();
            return mapper.writeValueAsString(resultMessage);
        }catch (JsonProcessingException e){
            e.printStackTrace();
        }
        return null;
    }

    public static String getMessage(Contact contact){
        try{
            ObjectMapper mapper = new ObjectMapper();
            return mapper.writeValueAsString(contact);
        }catch (JsonProcessingException e){
            e.printStackTrace();
        }
        return null;
    }
}
